home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / mxlibs / gusdk222 / source / example.c < prev    next >
Encoding:
Text File  |  1994-06-07  |  10.3 KB  |  322 lines

  1. indVesaMode(xsize,ysize,24);
  2.     END;
  3.     IF mode = 0 THEN BEGIN
  4.         WriteLn('No such mode could be found !');
  5.         WriteLn('Switching to to 320x200.');
  6.         ReadKey;
  7.         mode := V320x200x256;
  8.     END;
  9. END;
  10.  
  11. begin { program body }
  12.   SelectMode;
  13.   Initialize;
  14.   ReportStatus;
  15.  
  16. {  AspectRatioPlay; }
  17.   FillEllipsePlay;
  18.   SectorPlay;
  19.   WriteModePlay;
  20.  
  21.   ColorPlay;
  22.   { PalettePlay only intended to work on these drivers: }
  23.   if (GraphDriver = EGA) or
  24.       (GraphDriver = EGA64) or
  25.       (GraphDriver = VGA) then
  26.      PalettePlay;
  27.   PutPixelPlay;
  28. {  PutImagePlay; }
  29.   RandBarPlay;
  30.   BarPlay;
  31.   Bar3DPlay;
  32.   ArcPlay;
  33.   CirclePlay;
  34.   PiePlay;
  35.   LineToPlay;
  36.   LineRelPlay;
  37. {  LineStylePlay; }
  38. {  UserLineStylePlay; }
  39.   TextDump;
  40.   TextPlay;
  41.   CrtModePlay;
  42.   FillStylePlay;
  43.   FillPatternPlay;
  44.   PolyPlay;
  45.   SayGoodbye;
  46. {  CloseGraph; }
  47.   CloseVesa;
  48. end.
  49. ***************************************************
  50.     '* SHOW D2ROTATE (ABOUT THE ORIGIN)
  51.     '****************************************************************∞╥≤c≤*φè#^│v/╒:j═φ0t+l▓ô"¬"g└≡?%ªêΣ│H╫½╫╜├¿U'╒⌐⌡ ßV?╩¬ujOΦçEZ1∞▐! ▄B╛Σ8║æ]1GlNÜ┐q▌▓;ô$ΦzE<cª*bEô#ä╧ñÅ"∩─LrdaÖ ╠º╫a^¥£å╬1~)@ëÖMδ╫0═6DäFê¬Çv┼ß╨kæpτ╪É)}ª 1w3╤╧ü⌡¥╓h▓╣≈ïÅaÑ[TⁿHqªÉ╝DKÄ─Y-∞tT╤Θ╨º╟╪.*ÇI9lΦ≈{πτcσ$τπßoFr╪╨∩┼╞╟;O2■e²LÜ4^N|╪½ÅO?╔°FOz`╟╟╟'<>>π$πΘù6·Xgî╖│°oîδπGƒd╝▀░?■╪╔_9L ⌡ôⁿq'æO▀ƒn4╔▀╚▄┼3pτ.òO°·}÷╕ⁿ±'æO?ít│!√8ßÑ≤/┐╣p┼≥┘E╦Vox╕cΦé5╟╚º╙$?√$≥ΘZεsî≡åìΓpKù¢ïß X╥ 9╞≈\µk┤O¥_ 5Üö\≤éÄ┌╤A[╤ÿáï┼éNⁿÅu16    g,%hc╙╨cD╨Vï┘R¢öKñR;8εáΣ╢╪ós╤π╡á└èxgzPÄMú╫yαºÉ+σJ¢i+▓â3╥    ═Ñ╙î^ºG▓█πérφçs %#(╗⌠?┼%u8≡6+QÉ))ò)Afw≈╣╪)B&4░åLXV:δät@Å.;5Φf╢Ät┐ΣJ╫─U8úÇ╟éö£╕p╔┴⌠vg╨╬╥é÷╪╣┬ΓI.ç≡^v╤ZΦÇ& ╒┌6ñô6XßNè╡╬E₧Ñ
  52. kIº╠▄A+╣╥éb²tæ-Y¡½αÑa═uuîÇ╢αêvhuª╡SÅ┤vèùú¥F;p<d⌐/F─d█éT%▓KΦû=q■öI┐ ┐╠6S$▒÷╚ENΩ¥Fû9╔┌R'╝ ╧φ└?g┬j▓0═/b╖₧─mûé╢┌»ÿÄë/·<éò■░╤╟╢├Xσ:╥P3Θ"╬Læsφ░┌öSö!╗¿*mN£WΣÇ£┤~#╗ææ≥RΩóh:à▌.æ≈╕▌v£äàd▒à╒├=░╖π║$howeg*╬    6ù▄ƒô╕φ░Ö╢qΘD>(w@úKεHÆ╛öúΣU
  53. éÜR╔╤W▄èê 2M%ó.▓SNÖA1ùJE╢║l]▓¿>\%└Å4ßO▄£â⌐& ê/)8vSP▀▓ôⁿææ√ü√ÑÄa⌠â╚4S╓╟P- ?Σá╕▓Næ*q╡UΘ▓≈^ñ·I.rúR&$Y^╚%è≡B┌≈Ceat
  54.     Color := RandColor;
  55.     SetColor(Color);
  56.     SetFillStyle(Random(CloseDotFill)+1, Color);
  57.     Bar3D(Random(MaxWidth), Random(MaxHeight),
  58.           Random(MaxWidth), Random(MaxHeight), 0, TopOff);
  59.   until KeyPressed;
  60.   WaitToGo;
  61. end; { RandBarPlay }
  62.  
  63. procedure ArcPlay;
  64. { Draw random arcs on the screen }
  65. var
  66.   MaxRadius : word;
  67.   EndAngle : word;
  68.   ArcInfo : ArcCoordsType;
  69. begin
  70.   MainWindow('Arc / GetArcCoords demonstration');
  71.   StatusLine('Esc aborts or press a key');
  72.   MaxRadius := MaxY div 10;
  73.   repeat
  74.     SetColor(RandColor);
  75.     EndAngle := Random(360);
  76.     SetLineStyle(SolidLn, 0, NormWidth);
  77.     Arc(Random(MaxX), Random(MaxY), Random(EndAngle), EndAngle, Random(MaxRadius));
  78.     GetArcCoords(ArcInfo);
  79.     with ArcInfo do
  80.     begin
  81.       Line(X, Y, XStart, YStart);
  82.       Line(X, Y, Xend, Yend);
  83.     end;
  84.   until KeyPressed;
  85.   WaitToGo;
  86. end; { ArcPlay }
  87.  
  88. procedure PutPixelPlay;
  89. { Demonstrate the PutPixel and GetPixel commands }
  90. const
  91.   Seed   = 1962; { A seed for the random number generator }
  92.   NumPts = 2000; { The number of pixels plotted }
  93.   Esc    = #27;
  94. var
  95.   I : word;
  96.   X, Y, Color : word;
  97.   XMax, YMax  : integer;
  98.   ViewInfo    : ViewPortType;
  99. begin
  100.   MainWindow('PutPixel / GetPixel demonstration');
  101.   StatusLine('Esc aborts or press a key...');
  102.  
  103.   GetViewSettings(ViewInfo);
  104.   with ViewInfo do
  105.   begin
  106.     XMax := (x2-x1-1);
  107.     YMax := (y2-y1-1);
  108.   end;
  109.  
  110.   while not KeyPressed do
  111.   begin
  112.     { Plot random pixels }
  113.     RandSeed := Seed;
  114.     I := 0;
  115.     while (not KeyPressed) and (I < NumPts) do
  116.     begin
  117.       Inc(I);
  118.         PutPixel(Random(XMax)+1, Random(YMax)+1, RandColor);
  119.     end;
  120.  
  121.     { Erase pixels }
  122.     RandSeed := Seed;
  123.     I := 0;
  124.     while (not KeyPressed) and (I < NumPts) do
  125.     begin
  126.       Inc(I);
  127.       X := Random(XMax)+1;
  128.       Y := Random(YMax)+1;
  129.       Color := GetPixel(X, Y);
  130.         if Color = RandColor then
  131.           PutPixel(X, Y, 0);
  132.      end;
  133.   end;
  134.   WaitToGo;
  135. end; { PutPixelPlay }
  136.  
  137. procedure PutImagePlay;
  138. { Demonstrate the GetImage and PutImage commands }
  139.  
  140. const
  141.   r  = 20;
  142.   StartX = 100;
  143.   StartY = 50;
  144.  
  145. var
  146.   CurPort : ViewPortType;
  147.  
  148. procedure MoveSaucer(var X, Y : integer; Width, Height : integer);
  149. var
  150.   Step : integer;
  151. begin
  152.   Step := Random(2*r);
  153.   if Odd(Step) then
  154.     Step := -Step;
  155.   X := X + Step;
  156.   Step := Random(r);
  157.   if Odd(Step) then
  158.     Step := -Step;
  159.   Y := Y + Step;
  160.  
  161.   { Make saucer bounce off viewport walls }
  162.   with CurPort do
  163.   begin
  164.     if (x1 + X + Width - 1 > x2) then
  165.       X := x2-x1 - Width + 1
  166.     else
  167.       if (X < 0) then
  168.         X := 0;
  169.     if (y1 + Y + Height - 1 > y2) then
  170.       Y := y2-y1 - Height + 1
  171.     else
  172.       if (Y < 0) then
  173.         Y := 0;
  174.   end;
  175. end; { MoveSaucer }
  176.  
  177. var
  178.   Pausetime : word;
  179.   Saucer    : pointer;
  180.   X, Y      : integer;
  181.   ulx, uly  : word;
  182.   lrx, lry  : word;
  183.   Size      : word;
  184.   I         : word;
  185. begin
  186.   ClearDevice;
  187.   FullPort;
  188.  
  189.   { PaintScreen }
  190.   ClearDevice;
  191.   MainWindow('GetImage / PutImage Demonstration');
  192.   StatusLine('Esc aborts or press a key...');
  193.   GetViewSettings(CurPort);
  194.  
  195.   { DrawSaucer }
  196.   Ellipse(StartX, StartY, 0, 360, r, (r div 3)+2);
  197.   Ellipse(StartX, StartY-4, 190, 357, r, r div 3);
  198.   Line(StartX+7, StartY-6, StartX+10, StartY-12);
  199.   Circle(StartX+10, StartY-12, 2);
  200.   Line(StartX-7, StartY-6, StartX-10, StartY-12);
  201.   Circle(StartX-10, StartY-12, 2);
  202.   SetFillStyle(SolidFill, MaxColor);
  203.   FloodFill(StartX+1, StartY+4, GetColor);
  204.  
  205.   { ReadSaucerImage }
  206.   ulx := StartX-(r+1);
  207.   uly := StartY-14;
  208.   lrx := StartX+(r+1);
  209.   lry := StartY+(r div 3)+3;
  210.  
  211.   Size := ImageSize(ulx, uly, lrx, lry);
  212.   GetMem(Saucer, Size);
  213.   GetImage(ulx, uly, lrx, lry, Saucer^);
  214. {  PutImage(ulx, uly, Saucer^, XORput);               { erase image }
  215.  
  216.   { Plot some "stars" }
  217.   for I := 1 to 1000 do
  218.      PutPixel(Random(MaxX), Random(MaxY), RandColor);
  219.   X := MaxX div 2;
  220.   Y := MaxY div 2;
  221.   PauseTime := 70;
  222.  
  223.   { Move the saucer around }
  224.   repeat
  225. {     PutImage(X, Y, Saucer^, XORput);                 { draw image }
  226.      Delay(PauseTime);
  227. {     PutImage(X, Y, Saucer^, XORput);                 { erase image }
  228.      MoveSaucer(X, Y, lrx - ulx + 1, lry - uly + 1);  { width/height }
  229.   until KeyPressed;
  230.   FreeMem(Saucer, size);
  231.   WaitToGo;
  232. end; { PutImagePlay }
  233.  
  234. procedure PolyPlay;
  235. { Draw random polygons with random fill styles on the screen }
  236. const
  237.   MaxPts = 5;
  238. type
  239.   PolygonType = array[1..MaxPts] of PointType;
  240. var
  241.   Poly : PolygonType;
  242.   I, Color : word;
  243. begin
  244.   MainWindow('FillPoly demonstration');
  245.   StatusLine('Esc aborts or press a key...');
  246.   repeat
  247.     Color := RandColor;
  248.     SetFillStyle(Random(11)+1, Color);
  249.     SetColor(Color);
  250.     for I := 1 to MaxPts do
  251.       with Poly[I] do
  252.       begin
  253.         X := Random(MaxX);
  254.         Y := Random(MaxY);
  255.       end;
  256.     FillPoly(MaxPts, Poly);
  257.   until KeyPressed;
  258.   WaitToGo;
  259. end; { PolyPlay }
  260.  
  261. procedure FillStylePlay;
  262. { Display all of the predefined fill styles available }
  263. var
  264.   Style    : word;
  265.   Width    : word;
  266.   Height   : word;
  267.   X, Y     : word;
  268.   I, J     : word;
  269.   ViewInfo : ViewPortType;
  270.  
  271. procedure DrawBox(X, Y : word);
  272. begin
  273.   SetFillStyle(Style, MaxColor);
  274.   with ViewInfo do
  275.     Bar(X, Y, X+Width, Y+Height);
  276.   Rectangle(X, Y, X+Width, Y+Height);
  277.   OutTextXY(X+(Width div 2), Y+Height+4, Int2Str(Style));
  278.   Inc(Style);
  279. end; { DrawBox }
  280.  
  281. begin
  282.   MainWindow('Pre-defined fill styles');
  283.   GetViewSettings(ViewInfo);
  284.   with ViewInfo do
  285.   begin
  286.     Width := 2 * ((x2+1) div 13);
  287.     Height := 2 * ((y2-10) div 10);
  288.   end;
  289.   X := Width div 2;
  290.   Y := Height div 2;
  291.   Style := 0;
  292.   for J := 1 to 3 do
  293.   begin
  294.     for I := 1 to 4 do
  295.     begin
  296.       DrawBox(X, Y);
  297.       Inc(X, (Width div 2) * 3);
  298.     end;
  299.     X := Width div 2;
  300.     Inc(Y, (Height div 2) * 3);
  301.   end;
  302.   SetTextJustify(LeftText, TopText);
  303.   WaitToGo;
  304. end; { FillStylePlay }
  305.  
  306. procedure FillPatternPlay;
  307. { Display some user defined fill patterns }
  308. const
  309.   Patterns : array[0..11] of FillPatternType = (
  310.   ($AA, $55, $AA, $55, $AA, $55, $AA, $55 üÖü üÖü  !BBäx!!!BBäx!BBäx"""DDêp""DDêp>"""BBääêp""!"BDäêêp>IÉÆ|      ° @≥î>00>><Dêx  !BBäx""DDêp&<"DDêê&22TTêêê$> $< @äêp>          ⁿBBBB<  @@Ç****DDDDDDDU¬U¬U¬U¬U¬U¬U¬▌w▌w▌w▌w▌w▌w▌w°°°≥■°°≥≥■≥≥■■°°°    ≤  ≤  ≤≤         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       ;DDD;    $"Bdÿ>@@@>||>Ac]AAA1N"A""2,  `1NA"*III*<Bü üB<<BüüüB<A" \"QIE" < <BBBB  @@    ~ ?  @ÇB$$B ""A$$"AII6 üBr»$**IIII**ccregion.  The region is defined as any pixel of
  311.             OldColor which has a path of pixels of OldColor or NewColor
  312.             with sides touching back to the seed point, (XSeed, YSeed).
  313.             Therefore, only pixels of OldColor are modified and no other
  314.             information is changed.
  315.  
  316.             SEE ALSO
  317.  
  318.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  319.             FILLCONVEXPOLY, FILLPAGE, FILLPOLY, FILLSCREEN, FILLVIEW,
  320.             SETVIEW
  321.  
  322.             EXAMPL(HNxHHO$B<BBBB<$<BBBB<<BBBB<$BBBBBF:0BBBBF:$BBBF:B<""AAA""AAAAA"<B@@B<" <2\A">>xDDxDNDD <` <>BB= > <BBBB< BBBBF:2L\bBBBB&AaQIECA8$>""">0@@A>@@@